<template>
  <div class="cxy-page">
    <button class="banckbtn" @click="backbtnclick"></button>
    

    <!-- 0 -->
    <div class="reg-page zero" :style="{'transition': 'left 0.5s','left':index[0]+'%',}">
      <h1 class="reg-title">欢迎加入成叙缘</h1>
      <input type="text" name="" 
        placeholder-class="place-holder" 
        placeholder="请输入用户名">
      <input type="password" name="" 
        placeholder-class="place-holder"
        placeholder="请输入密码">
      <input type="password" name=""
        placeholder-class="place-holder" 
        placeholder="请确认密码">
      <button class="step one-btn" @click='next_one'>下一步</button>
    </div>

    <!-- 1 -->
    <div class="reg-page one" :style="{'transition': 'left 0.5s','left':index[1]+'%',}">
      <h1 class="reg-title">让大家认识更好的你</h1>
      <!-- <img :src="imgurl" class="myimg" @click='findImg' mode='aspectFill'> -->
      <img :src="imgurl" class="myimg" @click='findImg' :mode="hasImg ? 'aspectFill':'aspectFit'">
      <input type="text" name="" 
        placeholder-class="place-holder" 
        placeholder="请输入名字">
      <div class="btnpanle">
        <button class="step last" @click='last_one'>上一步</button>
        <button class="step next" @click='next_one'>下一步</button>
      </div>
    </div>

    <!-- 2 -->

    <div class="reg-page two" :style="{'transition': 'left 0.5s','left':index[2]+'%'}">
      <div class="itemdiv">
        <h1 class="reg-title">你的性别</h1>
        <div class="btnpanle">
          <button class="sexbtn" :class="sexindex == 1? 'sexbtn-active':''" @click='sexbtnClick(1)'>男</button>
          <button class="sexbtn" :class="sexindex == 0? 'sexbtn-active':''" @click='sexbtnClick(0)'>女</button>
        </div>
      </div>
      <div class="itemdiv">
        <h1 class="reg-title">你的生日</h1>
        <picker class="datepicker" 
            @change='birthChange'
            mode="date">
          <div class="birth-selectedview">
             {{'1990-01-01'}}
          </div>
        </picker>
      </div>
      <div class="itemdiv">
        <h1 class="reg-title">状态</h1>
        <input type="text" 
          disabled="disabled" 
          name="" 
          placeholder="请选择" 
          data-value='st'
          @click='showStatusSheet'>
      </div>

      <div class="btnpanle">
        <button class="step last" @click='last_one'>上一步</button>
        <button class="step next" @click='next_one'>继续</button>
      </div>
    </div>


    <!-- 3 -->
    <div class="reg-page three" :style="{'transition': 'left 0.5s','left':index[3]+'%',}">
    
        <div class="itemdiv">
          <h1 class="reg-title">所在城市</h1>
            <picker class="pick-city-three" 
            placeholder="所在城市"
            @change='bindRegionChange'
            mode="region">
            <div class="city-selectedview">
               <span>所在城市</span> {{3456789}}
            </div>
          </picker>
        </div>

        <div class="itemdiv">
          <h1 class="reg-title">工作</h1>
          <input type="text" 
            name="" 
            placeholder="请输入工作名称">
        </div>




      <div class="btnpanle">
        <button class="step last" @click='last_one'>上一步</button>
        <button class="step next" @click='donebtnClick'>完成</button>
      </div>

    </div>
  </div>
</template>

<script>
  export default {
    onLoad(){
      this.index = [0,100,200,300];
    },
    mounted(){

    },
    data(){
      return {
        hasImg:false,
        imgurl:'https://s1.ax1x.com/2018/10/31/iRTqeA.png',
        sexindex:-1,
        index:[],
        statuss:['未婚','离异'],
      }
    },
    methods:{
      backbtnclick(){
        wx.navigateBack()
      },
      next_one(){
        this.forleft();
      },
      forleft() {
          let arr = this.index.map(function(v) {
            let result = v - 100;
            return result;
        });
        this.index = arr;
      },
      forright() {
          let arr = this.index.map(function(v) {
            let result = v + 100;
            return result;
        });
        this.index = arr;
      },
      birthChange(e) {
        let date = e.mp.detail.value;
        console.log(date);
      },
      last_one(){
        this.forright();
      },
      donebtnClick (){
        // wx.navigateBack({url:'../profile/main'});
        wx.navigateBack();
      },
      showStatusSheet(e){
        let dv = e.currentTarget.dataset['value'];
        if (dv != 'st') {
          return;
        }
        let self = this;
        wx.showActionSheet({  
            itemList: self.statuss,
            success: function(res) {  
                self.info.status = self.statuss[res.tapIndex];
            }
        });
      },
      bindRegionChange(e){
        let arr = e.mp.detail.value;
      },
      sexbtnClick(n){
        this.sexindex = n;
      },
      findImg() {
        let self = this;
        wx.chooseImage({
          count:1,
          sourceType: ['album', 'camera'],
          success:function (res) {
            self.hasImg = true;
            self.imgurl = res.tempFilePaths;
          }
        });
      }
    },
  }
</script>

<style scoped>
.cxy-page {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.banckbtn::after {
  border:none;
}
.banckbtn {
  z-index: 99;
  position: fixed;
  width: 80px;
  height: 40px;
  left: 25px;
  top: 30px;
  background-image: url();
    background-size: 30%;
    background-position: left;
    background-repeat: no-repeat;
    background-color: rgba(0,0,0,0);
}
.reg-page {
  position: absolute;
  display: block;
  width: 100%;
  height: calc(100% - 64px);
  top:64px;
  left:0;
  text-align: center;
}
.zero {
  left: 0;
  background-color: white;
}
.one {
  left: 100%;
  background-color: white;
}

.reg-title {
  display: block;
  margin-top: 40px;
  font-size: 25px;
  font-weight: 100;
}

.myimg {
  margin-top: 20px;
  background-color: #f5f5f5;
  max-height: 216px;
  overflow: hidden;
}

input {
  margin-top: 20px;
  border-bottom: 1px solid #d8d8d8;
  display: block;
  width: 100%;
  height: 64px;
  font-size: 20px;
  text-align: center;
  font-weight: 400px;
}

button::after {
  border: none;
}

.place-holder {
  color: red;
}

.step {
  display: block;
  height: 45px;
  line-height: 45px;
  font-weight: 400;
  width: calc(100% - 50px);
  border-radius: calc(45px / 2);
  background-image: linear-gradient(-134deg, #4078EF 0%, #5BD8F2 100%);
  color: white;
  margin-top: 60px;
}
/**************************/
.two {
  left: 200%;
  background-color: #fff;
}

.itemdiv {
  max-height: 30%;
}

.btnpanle {
  display: flex;
  justify-content: center;
}

.sexbtn {
  width: 70px;
  height: 70px;
  line-height: 70px;
  font-size: 22px;
  font-weight: 200;
  border: 1px solid #f1f1f1;
  border-radius: 35px;
}

.sexbtn-active {
  color: white;
  background-image: linear-gradient(120deg, #89f7fe 0%, #66a6ff 100%);
}

.datepicker {
  margin-top: 20px;
  padding-bottom: 15px;
}

.last {
  width: 120px;
}
.next{
  width: 120px; 
}

.birth-selectedview {
  color: #979797;
}

/**/

.three {
  left: 300%;
  background-color: #fff;
}
.pick-city-three {
  margin-top: 20px;
}
.three .city-selectedview {
  color: #979797;
}
</style>
